.class public Lrexsee/core/browser/clazz/BrowserClient;
.super Landroid/webkit/WebViewClient;
.source "BrowserClient.java"


# static fields
.field private static final TARGET_PREFIX:Ljava/lang/String; = "#target="


# instance fields
.field private final mBrowser:Lrexsee/core/browser/Browser;

.field private final mContext:Landroid/content/Context;


# direct methods
.method public constructor <init>(Lrexsee/core/browser/Browser;)V
    .locals 1
    .param p1, "browser"    # Lrexsee/core/browser/Browser;

    .prologue
    .line 15
    invoke-direct {p0}, Landroid/webkit/WebViewClient;-><init>()V

    .line 16
    iput-object p1, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    .line 17
    invoke-virtual {p1}, Lrexsee/core/browser/Browser;->getContext()Landroid/content/Context;

    move-result-object v0

    iput-object v0, p0, Lrexsee/core/browser/clazz/BrowserClient;->mContext:Landroid/content/Context;

    .line 18
    return-void
.end method


# virtual methods
.method public onLoadResource(Landroid/webkit/WebView;Ljava/lang/String;)V
    .locals 2
    .param p1, "view"    # Landroid/webkit/WebView;
    .param p2, "url"    # Ljava/lang/String;

    .prologue
    .line 45
    iget-object v0, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->loadResourceListeners:Lrexsee/core/browser/clazz/LoadResourceListeners;

    iget-object v1, p0, Lrexsee/core/browser/clazz/BrowserClient;->mContext:Landroid/content/Context;

    check-cast p1, Lrexsee/core/browser/Browser;

    .end local p1    # "view":Landroid/webkit/WebView;
    invoke-virtual {v0, v1, p1, p2}, Lrexsee/core/browser/clazz/LoadResourceListeners;->run(Landroid/content/Context;Lrexsee/core/browser/Browser;Ljava/lang/String;)V

    .line 46
    return-void
.end method

.method public onPageFinished(Landroid/webkit/WebView;Ljava/lang/String;)V
    .locals 6
    .param p1, "view"    # Landroid/webkit/WebView;
    .param p2, "url"    # Ljava/lang/String;

    .prologue
    const-string v4, "}"

    .line 54
    const-string v1, "javascript:"

    .line 55
    .local v1, "updateLinkJs":Ljava/lang/String;
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "var allLinks = document.getElementsByTagName(\'a\'); "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 56
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "if (allLinks) {"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 57
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "var i;for (i=0; i<allLinks.length; i++) {"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 58
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "var link = allLinks[i];"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 59
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "var target = link.getAttribute(\'target\'); "

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 60
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "if (target ) {"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 61
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "var newHref = link.href;"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 62
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "if( newHref == document.location.href ) newHref = newHref + \'#\';"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 63
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "newHref = newHref + \'#target=\' + target ;"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 64
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "link.href = newHref;"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 65
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "}"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 66
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "}"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 67
    new-instance v2, Ljava/lang/StringBuilder;

    invoke-static {v1}, Ljava/lang/String;->valueOf(Ljava/lang/Object;)Ljava/lang/String;

    move-result-object v3

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    const-string v3, "}"

    invoke-virtual {v2, v4}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v1

    .line 68
    iget-object v2, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    invoke-virtual {v2, v1}, Lrexsee/core/browser/Browser;->loadUrl(Ljava/lang/String;)V

    .line 69
    iget-object v2, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v3, v2, Lrexsee/core/browser/Browser;->pageReadyListeners:Lrexsee/core/browser/clazz/PageReadyListeners;

    iget-object v4, p0, Lrexsee/core/browser/clazz/BrowserClient;->mContext:Landroid/content/Context;

    move-object v0, p1

    check-cast v0, Lrexsee/core/browser/Browser;

    move-object v2, v0

    iget-object v5, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v5, v5, Lrexsee/core/browser/Browser;->history:Lrexsee/core/browser/clazz/History;

    invoke-virtual {v5}, Lrexsee/core/browser/clazz/History;->getCurrentItem()Lrexsee/core/browser/clazz/HistoryItem;

    move-result-object v5

    invoke-virtual {v5}, Lrexsee/core/browser/clazz/HistoryItem;->getUrl()Ljava/lang/String;

    move-result-object v5

    invoke-virtual {v3, v4, v2, v5}, Lrexsee/core/browser/clazz/PageReadyListeners;->run(Landroid/content/Context;Lrexsee/core/browser/Browser;Ljava/lang/String;)V

    .line 70
    iget-object v2, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v2, v2, Lrexsee/core/browser/Browser;->eventList:Lrexsee/core/browser/clazz/EventList;

    iget-object v3, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v3, v3, Lrexsee/core/browser/Browser;->EVENT_ONREXSEEREADY:Ljava/lang/String;

    invoke-virtual {v2, v3}, Lrexsee/core/browser/clazz/EventList;->run(Ljava/lang/String;)V

    .line 71
    new-instance v2, Ljava/lang/StringBuilder;

    const-string v3, "javascript: try { "

    invoke-direct {v2, v3}, Ljava/lang/StringBuilder;-><init>(Ljava/lang/String;)V

    iget-object v3, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v3, v3, Lrexsee/core/browser/Browser;->application:Lrexsee/core/application/RexseeApplication;

    iget-object v3, v3, Lrexsee/core/application/RexseeApplication;->resources:Lrexsee/core/application/Resource;

    iget-object v3, v3, Lrexsee/core/application/Resource;->prefix:Ljava/lang/String;

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    const-string v3, "Browser.setSource(document.documentElement.outerHTML); } catch(e) {}"

    invoke-virtual {v2, v3}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;

    move-result-object v2

    invoke-virtual {v2}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {p1, v2}, Landroid/webkit/WebView;->loadUrl(Ljava/lang/String;)V

    .line 72
    return-void
.end method

.method public onPageStarted(Landroid/webkit/WebView;Ljava/lang/String;Landroid/graphics/Bitmap;)V
    .locals 3
    .param p1, "view"    # Landroid/webkit/WebView;
    .param p2, "url"    # Ljava/lang/String;
    .param p3, "favicon"    # Landroid/graphics/Bitmap;

    .prologue
    .line 49
    iget-object v0, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v0, v0, Lrexsee/core/browser/Browser;->pageStartedListeners:Lrexsee/core/browser/clazz/PageStartedListeners;

    iget-object v1, p0, Lrexsee/core/browser/clazz/BrowserClient;->mContext:Landroid/content/Context;

    check-cast p1, Lrexsee/core/browser/Browser;

    .end local p1    # "view":Landroid/webkit/WebView;
    iget-object v2, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v2, v2, Lrexsee/core/browser/Browser;->history:Lrexsee/core/browser/clazz/History;

    invoke-virtual {v2}, Lrexsee/core/browser/clazz/History;->getCurrentItem()Lrexsee/core/browser/clazz/HistoryItem;

    move-result-object v2

    invoke-virtual {v2}, Lrexsee/core/browser/clazz/HistoryItem;->getUrl()Ljava/lang/String;

    move-result-object v2

    invoke-virtual {v0, v1, p1, v2, p3}, Lrexsee/core/browser/clazz/PageStartedListeners;->run(Landroid/content/Context;Lrexsee/core/browser/Browser;Ljava/lang/String;Landroid/graphics/Bitmap;)V

    .line 50
    return-void
.end method

.method public onReceivedError(Landroid/webkit/WebView;ILjava/lang/String;Ljava/lang/String;)V
    .locals 7
    .param p1, "view"    # Landroid/webkit/WebView;
    .param p2, "errorCode"    # I
    .param p3, "description"    # Ljava/lang/String;
    .param p4, "failingUrl"    # Ljava/lang/String;

    .prologue
    .line 75
    invoke-virtual {p1}, Landroid/webkit/WebView;->stopLoading()V

    .line 76
    iget-object v1, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v2, v1, Lrexsee/core/browser/Browser;->progressListeners:Lrexsee/core/browser/clazz/LoadingProgressListeners;

    iget-object v3, p0, Lrexsee/core/browser/clazz/BrowserClient;->mContext:Landroid/content/Context;

    move-object v0, p1

    check-cast v0, Lrexsee/core/browser/Browser;

    move-object v1, v0

    const/16 v4, 0x64

    invoke-virtual {v2, v3, v1, v4}, Lrexsee/core/browser/clazz/LoadingProgressListeners;->run(Landroid/content/Context;Lrexsee/core/browser/Browser;I)V

    .line 77
    iget-object v1, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v1, v1, Lrexsee/core/browser/Browser;->errorListeners:Lrexsee/core/browser/clazz/ErrorListeners;

    iget-object v2, p0, Lrexsee/core/browser/clazz/BrowserClient;->mContext:Landroid/content/Context;

    move-object v0, p1

    check-cast v0, Lrexsee/core/browser/Browser;

    move-object v3, v0

    iget-object v4, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v4, v4, Lrexsee/core/browser/Browser;->history:Lrexsee/core/browser/clazz/History;

    invoke-virtual {v4}, Lrexsee/core/browser/clazz/History;->getCurrentItem()Lrexsee/core/browser/clazz/HistoryItem;

    move-result-object v4

    invoke-virtual {v4}, Lrexsee/core/browser/clazz/HistoryItem;->getUrl()Ljava/lang/String;

    move-result-object v6

    move v4, p2

    move-object v5, p3

    invoke-virtual/range {v1 .. v6}, Lrexsee/core/browser/clazz/ErrorListeners;->run(Landroid/content/Context;Lrexsee/core/browser/Browser;ILjava/lang/String;Ljava/lang/String;)V

    .line 78
    return-void
.end method

.method public onReceivedSslError(Landroid/webkit/WebView;Landroid/webkit/SslErrorHandler;Landroid/net/http/SslError;)V
    .locals 0
    .param p1, "view"    # Landroid/webkit/WebView;
    .param p2, "handler"    # Landroid/webkit/SslErrorHandler;
    .param p3, "error"    # Landroid/net/http/SslError;

    .prologue
    .line 81
    invoke-virtual {p2}, Landroid/webkit/SslErrorHandler;->proceed()V

    .line 82
    return-void
.end method

.method public shouldOverrideUrlLoading(Landroid/webkit/WebView;Ljava/lang/String;)Z
    .locals 11
    .param p1, "view"    # Landroid/webkit/WebView;
    .param p2, "url"    # Ljava/lang/String;

    .prologue
    const/4 v6, 0x0

    const/4 v10, 0x1

    const-string v7, "#target="

    .line 21
    if-nez p2, :cond_0

    move v5, v10

    .line 40
    :goto_0
    return v5

    .line 22
    :cond_0
    const-string v3, "_self"

    .line 23
    .local v3, "target":Ljava/lang/String;
    const-string v5, "#target="

    invoke-virtual {p2, v7}, Ljava/lang/String;->contains(Ljava/lang/CharSequence;)Z

    move-result v5

    if-eqz v5, :cond_1

    .line 24
    const-string v5, "#target="

    invoke-virtual {p2, v7}, Ljava/lang/String;->split(Ljava/lang/String;)[Ljava/lang/String;

    move-result-object v2

    .line 25
    .local v2, "t":[Ljava/lang/String;
    aget-object v3, v2, v10

    .line 26
    aget-object p2, v2, v6

    .line 29
    .end local v2    # "t":[Ljava/lang/String;
    :cond_1
    :try_start_0
    iget-object v4, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    .line 30
    .local v4, "targetBrowser":Lrexsee/core/browser/Browser;
    const-string v5, "_blank"

    invoke-virtual {v3, v5}, Ljava/lang/String;->equalsIgnoreCase(Ljava/lang/String;)Z

    move-result v5

    if-eqz v5, :cond_2

    .line 31
    iget-object v5, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v5, v5, Lrexsee/core/browser/Browser;->windowListener:Lrexsee/core/browser/clazz/WindowCreateCloseListener;

    if-eqz v5, :cond_2

    .line 32
    iget-object v5, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    iget-object v5, v5, Lrexsee/core/browser/Browser;->windowListener:Lrexsee/core/browser/clazz/WindowCreateCloseListener;

    iget-object v6, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    const/4 v7, 0x0

    const/4 v8, 0x1

    const/4 v9, 0x1

    invoke-virtual {v5, v6, v7, v8, v9}, Lrexsee/core/browser/clazz/WindowCreateCloseListener;->getNewBrowser(Lrexsee/core/browser/Browser;ZZZ)Lrexsee/core/browser/Browser;

    move-result-object v1

    .line 33
    .local v1, "newBrowser":Lrexsee/core/browser/Browser;
    if-eqz v1, :cond_2

    move-object v4, v1

    .line 36
    .end local v1    # "newBrowser":Lrexsee/core/browser/Browser;
    :cond_2
    iget-object v5, v4, Lrexsee/core/browser/Browser;->function:Lrexsee/core/browser/RexseeBrowser;

    invoke-virtual {v5, p2}, Lrexsee/core/browser/RexseeBrowser;->load(Ljava/lang/String;)V
    :try_end_0
    .catch Ljava/lang/Exception; {:try_start_0 .. :try_end_0} :catch_0

    .end local v4    # "targetBrowser":Lrexsee/core/browser/Browser;
    :goto_1
    move v5, v10

    .line 40
    goto :goto_0

    .line 37
    :catch_0
    move-exception v5

    move-object v0, v5

    .line 38
    .local v0, "e":Ljava/lang/Exception;
    iget-object v5, p0, Lrexsee/core/browser/clazz/BrowserClient;->mBrowser:Lrexsee/core/browser/Browser;

    const-string v6, "WebViewClient.shouldOverrideUrlLoading"

    invoke-virtual {v5, v6, v0}, Lrexsee/core/browser/Browser;->exception(Ljava/lang/String;Ljava/lang/Exception;)V

    goto :goto_1
.end method
